{% extends "BackendBundle::backend.html.twig" %}

{% block js %}

   {% javascripts
        '@ConfigBundle/Resources/public/js/jquery.validate.js'
        '@ConfigBundle/Resources/public/js/Idiomes.js'
   %}
        <script src="{{ asset_url }}"></script>
   {% endjavascripts %}

{% endblock %}

{% block header %}

    {% set url = app.request.attributes.get('_route') %}
    {% set vars = {'ruta' : url} %}
    {% include "BackendBundle::topmenu.html.twig" with vars %}
        
{% endblock %}

{% block title "Configuración" %}

{% block left %}

{% endblock %}

{% block content %}

    {% if configActiu == 1 %}

        <div class="span12">

            <h2>{{ "Configuración"|trans }}</h2>

            <br />
            
            <form action="{{ path('ConfigBundle_guarda') }}" class="form-horizontal" method="post">
                <fieldset>
                    
                    <p><b>Bienvendido a la configuración de la web, solo tienes que responder a una pregunta para empezar a trabajar.</b></p>

                    <div class="control-group">
                        <label class="control-label">¿Eres una cadena de hoteles?</label>
                        <div class="controls">
                            <label class="radio">
                                <input name="cadena" id="optionsRadios1" value="2" checked="checked" type="radio"> Si
                            </label>
                            <label class="radio">
                                <input name="cadena" id="optionsRadios2" value="1" type="radio"> No
                            </label>
                        </div>
                    </div>
                    
                    <div class="form-actions">
                        <input type="submit" value="Guardar" />
                    </div>
                    
            </form>

        </div>
    
    {% else %}

        {% if app.session.hasFlash('success') %}
            <div class="flash-notice alert alert-success">
                <h4 class="alert-heading">Ok!</h4>                     
                {{ app.session.flash('success') }}
            </div>
        {% endif %}

        {% if app.session.hasFlash('error') %}
            <div class="flash-notice alert alert-error">
                <h4 class="alert-heading">Error!</h4>                        
                {{ app.session.flash('error') }}
            </div>
        {% endif %}

        {% if app.session.hasFlash('info') %}
            <div class="flash-notice alert alert-info">
                <h4 class="alert-heading">Info!</h4>
                <p>{{ app.session.flash('info') }}</p>
            </div>
        {% endif %}

        <h2>{{ "Configuración Inicial"|trans }}</h2>

        <div class="well">
        
            {%  if configuracio == 1 %}
                <p>El Gestor es configurado como <b>Hotel Individual</b></p>
            {% else %}
                <p>El Gestor es configurado como <b>Cadena de Hoteles</b></p>
            {% endif %}

        </div>
                
        <h2>{{ "Configuración de idiomas disponibles"|trans }}</h2>
        
        <div class="flash-notice alert alert-info">
            
            <h4 class="alert-heading">Info!</h4>
            <p>Aqui selecionamos los idiomas que tendra la web, la gestion se hace desde la pestanya <a href="{{ path('IdiomasBundle_homepage') }}">Idiomas</a>.</p>
            
        </div>
        
        <div class="row-fluid">

            <div class="span6">
                
                <div class="well" style="padding: 8px;">
                
                    <table class="table">
                        <thead>
                            <tr>
                                <th>#</th>
                                <th>{{ "Idioma"|trans }}</th>
                                <th>{{ "Codigo"|trans }}</th>
                            </tr>
                        </thead>
                        <tbody>        

                        {% for language in languages %}

                            <tr>
                                <td>{{language.id}}</td>
                                <td>{{language.idioma}}</td>
                                <td>{{language.codigo}}</td>
                            </tr>            

                        {% endfor %}

                        </tbody>
                    </table>
                    
                </div>
                
            </div>
            
            <div class="span6">
                
                <div class="well" style="padding: 20px;">
                    
                    {%  if dispolanguages != 0 %}
                    
                        <form action="{{ path('ConfigBundle_guardaidioma') }}" class="form-vertical" name="formidiomes" id="formidiomes" method="post">

                            <div class="row-fluid">

                                <div class="span5">
                                    <label class="control-label" for="idioma">{{ "Idioma"|trans }} *</label>
                                    <div class="controls">
                                        <input type="text" class="input-medium" name="idioma" id="idioma" />
                                    </div>
                                </div>

                                <div class="span5">
                                    <label class="control-label" for="codigo">{{ "Codigo"|trans }} *</label>
                                    <div class="controls">

                                        <select name="codigo" id="codigo">
                                            <option value="">Selecione</option>
                                            {% for dispolanguage in dispolanguages %}

                                            <option value="{{ dispolanguage.codigo }}">{{ dispolanguage.urlcodigo }} ({{ dispolanguage.codigo }})</option>

                                            {% endfor %}
                                        </select>

                                    </div>
                                </div>

                                <div class="span10"><input type="submit" value="Crear Idioma" /></div>

                            </div>

                        </form>
                    
                    {% else %}
                    
                       <p>No hay mas idiomas para activar</p> 
                    
                    {% endif %}
                    
                </div>
                
            </div>            
            
        </div>               

    {% endif %}

{% endblock %}



